package com.sinping.qh.dto.auth;/**
 * @copyright 2017 sinping.com
 *         <p>
 *         北京芯平科技股份有限公司. All rights reserved.
 *         本内容仅限于北京芯平科技股份有限公司内部传阅，禁止外泄以及用于其他的商业目的.
 */

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.sinping.qh.domain.auth.Resource;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * @类名称: ResourceDTO
 * @类描述: 资源DTO
 * @作者:杨云博
 * @创建时间:2017/12/25 11:18
 */

public class ResourceDTO implements Serializable{

    private static final long serialVersionUID = 7853691590832995049L;

    private String id;
    private String name;
    @JsonProperty(value = "uri")
    private String url;
    private Integer type;
    private Integer status;
    private Integer lev;
    @JsonProperty(value = "parent_id")
    private String parentId;
    private Integer code;
    private String permission;
    @JsonProperty("request_type")
    private String requestType;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", locale = "zh", timezone = "GMT+8")
    @JsonProperty(value = "create_time")
    private Date createTime;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", locale = "zh", timezone = "GMT+8")
    @JsonProperty(value = "update_time")
    private Date updateTime;
    private List<ResourceDTO> children;

    public ResourceDTO(){
        super();
    }

    public ResourceDTO(Resource resource){
        super();
        this.id = resource.getId();
        this.name = resource.getName();
        this.url = resource.getUrl();
        this.type = resource.getType();
        this.status = resource.getStatus();
        this.lev = resource.getLev();
        this.parentId = resource.getParentId();
        this.code = resource.getCode();
        this.permission = resource.getPermission();
        this.createTime = resource.getCreateTime();
        this.updateTime = resource.getUpdateTime();
        this.requestType = resource.getRequestType();
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public Integer getLev() {
        return lev;
    }

    public void setLev(Integer lev) {
        this.lev = lev;
    }

    public String getParentId() {
        return parentId;
    }

    public void setParentId(String parentId) {
        this.parentId = parentId;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getPermission() {
        return permission;
    }

    public void setPermission(String permission) {
        this.permission = permission;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }


    public List<ResourceDTO> getChildren() {
        return children;
    }

    public void setChildren(List<ResourceDTO> children) {
        this.children = children;
    }



    public Resource toResource(){
        Resource resource = new Resource();
        resource.setId(this.id);
        resource.setName(this.name);
        resource.setUrl(this.url);
        resource.setType(this.type);
        resource.setStatus(this.status);
        resource.setLev(this.lev);
        resource.setParentId(this.parentId);
        resource.setCode(this.code);
        resource.setPermission(this.permission);
        resource.setCreateTime(this.createTime);
        resource.setUpdateTime(this.updateTime);
        resource.setRequestType(this.requestType);

        return resource;
    }

    public String getRequestType() {
        return requestType;
    }

    public void setRequestType(String requestType) {
        this.requestType = requestType;
    }
}
